package example;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;

import java.util.Date;

/**
 * @oauth Yeohwah
 * @createDate 2019/8/26
 * @info 利用腾讯SCF函数服务，使用java语言每日签到领取腾讯视频V力值
 */
public class Hello {
    //在SCF中設置環境變量JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 否则中文乱码
    public String  mainHandler(String name) {
        System.out.println("开始执行腾讯视频签到");
        //这里是签到获取V值的cookie
        String cookieStr = "电脑端登录腾讯视频，访问下面地址，在console页输入document.cookie把所有cookie复制过来即可";
        //这里执行签到获取V值
        String resp = HttpRequest.get("https://vip.video.qq.com/fcgi-bin/comm_cgi?name=hierarchical_task_system&cmd=2&_=1").header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.204 Safari/537.36")
                .header("Cookie", cookieStr).execute().body();
        System.out.println(resp);
        //这里是发送签到结果到你的微信
        String httpRequest = HttpRequest.get("https://sc.ftqq.com/你在Server酱申请的key.send?text=" + "签到完成点击查看" + new Date().getTime() + "&desp=" + JSONUtil.parseObj(resp.replace("QZOutputJson=(", "").replace(")", "")).get("msg")).execute().body();
        System.out.println(httpRequest);
        System.out.println("执行腾讯视频签到结束");
        return "OK";
    }
}
